package com.example.money.test.RecyclerViewStudy;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.example.money.test.R;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class RecyleActivity extends AppCompatActivity {
    private RecyclerView mRecyclerView;
    private List<String> mListData = new ArrayList<>();
    private Toolbar mToolbar;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.recycle_layout);

        getData();

        init();
    }

    private void getData() {
        mListData = Arrays.asList("1","2","3","4","5","6","7","8","9","10",
                "11","12","13","14","15","16","17","18");
        Log.e("money", "getData: "+mListData);
    }

    private void init() {
        mRecyclerView = findViewById(R.id.id_recycle);
        mToolbar = this.findViewById(R.id.toolbar);

        setSupportActionBar(mToolbar);
        mToolbar.setTitle("RecyclerView学习");

//        LinearLayoutManager manager = new LinearLayoutManager(this);
//        manager.setOrientation(LinearLayoutManager.VERTICAL);//设置垂直排列

        RecyclerAdapter adapter = new RecyclerAdapter(mListData,this);
//
//        mRecyclerView.addItemDecoration(new DivideItemDecoration
//                (RecyleActivity.this,DivideItemDecoration.VERTICAL_LIST));
        //设置默认的item增添和删除动画
       // mRecyclerView.setLayoutManager(manager);
        //GridLayout样式
        mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager
                (4,StaggeredGridLayoutManager.VERTICAL));
        mRecyclerView.addItemDecoration(new DivideItemDecoration
                (RecyleActivity.this,DivideItemDecoration.HORIZONTAL_LIST));
        mRecyclerView.setAdapter(adapter);

    }
}
